/*
* Copyright (C) 2024-2025 Uniontech Technology Co., Ltd.
*
* Author:      zhangbingyi <zhangbingyi@uniontech.com>
*
* Maintainer:  zhangbingyi <zhangbingyi@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#include "widgets/defendertable.h"
#include "schedulescanitem.h"
#include "widgets/safetyprotectionitem.h"
#include "widgets/menuitem.h"
#include "widgets/multicombox.h"

//#include <DBlurEffectWidget>
#include <QTimeEdit>

#include <QButtonGroup>
#include <QObject>
#include <QRadioButton>

class SettingsInvokerInterface;
class DBusInvokerInterface;

// 定时扫描时间类型
enum ScheduleScanTimeType {
    Everyday = 0, // 每天
    Everyweek, // 每周
    Everymonth, // 每月
    CustomizeType //自定义
};

using namespace def::widgets;

class DEVCOMMONSHARED_EXPORT ScheduleScanView : public QFrame
{
    Q_OBJECT
public:
    explicit ScheduleScanView(QWidget *parent = nullptr);

    // 设置状态
    void setTimerUi(bool isStatus);

private:
    // 初始化界面
    void initUI();
    // 初始化数据
    void initData();

    // 根据开关状态置灰/置亮空间
    void setWidgetStatus(bool bStatus);
    // 定时时间gsetting设置
    void setTimeGsetting();

    // 添加安全日志
    QString getLogStr();
    // 处理每周 同名及转换字符串
    QString selectWeeksHandle();
    // 处理每月 同名及转换字符串
    QString selectMonthsHandle();

private Q_SLOTS:
    // 表格内下拉框选项改变
    void onAppOneChanged(int index);

    // 定时扫描总开关状态改变槽
    void acceptTimerScanSwitchStatusChange();

    // 定时快速扫描总类型改变槽
    void acceptTimerQuickScanTypeClicked();
    // 定时全盘扫描总类型改变槽
    void acceptTimerFullScanTypeClicked();

    // 定时扫描询问处理方式改变槽
    void acceptTimerAskHandleClicked();
    // 定时扫描自动处理方式改变槽
    void acceptTimerAutoHandleClicked();

    // 定时扫描日志每星期、每月时间跨度添加处理槽
    void addDayInEveryWeekOrMonthLog();
    // 定时扫描日志时间编辑添加处理槽
    void addTimeChangeLog();

    void onCurrentTextChangedOfMultiComboBox();
    void onDateChanged();
Q_SIGNALS:
    void sendSwitchChanged(bool isStatus);

private:
    DBusInvokerInterface *m_monitorNetFlowInter; // 系统服务
//    DBlurEffectWidget *m_blurEffect; // 透明背景
    ScheduleScanItem *m_setupItemNew; // 定时扫描设置选项
    QButtonGroup *m_pTypeButtonGrop; // 扫描类型按钮组
    QRadioButton *m_quickButton; // 快速扫描按钮
    QRadioButton *m_fullButton; // 全盘扫描按钮
    QButtonGroup *m_pFoundButtonGrop; // 发现病毒处理方式按钮组
    QRadioButton *m_askButton; // 询问按钮
    QRadioButton *m_autoButton; // 自动处理按钮
    QComboBox *m_timeSpanCombobox; // 时间跨度下拉框
    MultiComBox *m_dayOfMonthMultiComboBox; // 月份日期选择下拉框
    MultiComBox *m_dayOfWeekMultiComboBox; // 星期日期选择下拉框
    QDateEdit *m_dateEdit; // 日期编辑器
    QTimeEdit *m_timeEdit; // 时间编辑器
    QWidget *m_contentWidget; // 内容装置

    QTime m_defaultTime;
    SettingsInvokerInterface *m_gsetting; //安全中心gsetting配置
    bool m_timerScanSwitch;
    bool m_timerScanType;
    QString m_sScanTime;
    bool m_timerScanHandle;
};
